year = int(input())
month = int(input())
day = int(input())

# 每个月的天数，2月的天数需要根据是否是闰年调整
days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
    days_in_month[1] = 29

print(days_in_month[month - 1] - day)